package com.zzb.weixin;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.zzb.util.HTTPUtil;
import com.zzb.weixin.constant.Constant.WXLang;
import com.zzb.weixin.constant.Constant.WXMediaType;
import com.zzb.weixin.constant.Constant.WXOauthScope;
import com.zzb.weixin.constant.WXJsonName;
import com.zzb.weixin.constant.WXJsonValue;
import com.zzb.weixin.exception.WeiXinException;
import com.zzb.weixin.json.JSON;
import com.zzb.weixin.json.JsonObject;

public class WeiXinApi {
	private final static String end = "\r\n";
	private final static String twoHyphens = "--"; // 用于拼接

	public static JsonObject getAccessToken(String appId, String appSecret)
			throws WeiXinException {
		return HTTPUtil.doGet(WeiXinUrlService.getGetAccessTokenUrl(appId, appSecret));
	}

	/**
	 * 如果公众号基于安全等考虑，需要获知微信服务器的IP地址列表，以便进行相关限制，可以通过该接口获得微信服务器IP地址列表。
	 *
	 * @param accessToken
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getIPListAsJson(String accessToken)
			throws WeiXinException {
		return HTTPUtil.doGet(WeiXinUrlService.getGetIPListURL(accessToken));
	}

	/**
	 * 公众号可调用本接口来上传图片、语音、视频等文件到微信服务器，上传后服务器会返回对应的media_id，
	 * 公众号此后可根据该media_id来获取多媒体。请注意，media_id是可复用的，调用该接口需http协议。
	 * 
	 * @param file
	 * @param type
	 *            媒体文件类型，分别有图片（image）、语音（voice）、视频（video）和缩略图（thumb）
	 * @param accessToken
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject uploadMedia(File file, WXMediaType type,
			String accessToken) throws WeiXinException {
		JsonObject jo = null;
		try {
			String url = WeiXinUrlService.getUploadMediaUrl(accessToken, type);
			URL u = new URL(url);
			HttpURLConnection conn = (HttpURLConnection) u.openConnection();
			conn.setDoOutput(true);

			conn.setRequestMethod("POST");
			conn.setRequestProperty("Connection", "Keep-Alive");
			conn.setRequestProperty("Content-Type", "multipart/form-data;");
			// 获取输出流对象，准备上传文件
			OutputStream dos = conn.getOutputStream();
			dos.write((twoHyphens + end).getBytes());
			dos.write(("Content-Disposition: form-data; name=\""
					+ file.getName() + "\";filename=\"" + file.getName()
					+ ";filelength=\"" + file.length()
					+ "content-type=\"application/octet-stream\"" + end)
					.getBytes());
			dos.write(end.getBytes());
			// 对文件进行传输
			FileInputStream fis = new FileInputStream(file);
			byte[] buffer = new byte[1024]; // 1k
			int count = 0;
			while ((count = fis.read(buffer)) != -1) {
				dos.write(buffer, 0, count);
			}
			fis.close(); // 关闭文件流

			dos.write(end.getBytes());
			dos.write((twoHyphens + end).getBytes());
			dos.flush();
			dos.close();

			jo = JSON.parse(HTTPUtil.getContext(conn.getInputStream()));
			HTTPUtil.doExeption(jo);
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (ProtocolException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return jo;
	}

	/**
	 * 公众号可调用本接口来获取多媒体文件。请注意，视频文件不支持下载，调用该接口需http协议。
	 * 
	 * @param filepath
	 * @param mediaId
	 * @param accessToken
	 * @throws WeiXinException
	 */
	public static File downloadMedia(String filepath, String mediaId,
			String accessToken) throws WeiXinException {
		String url = WeiXinUrlService.getDownloadMediaUrl(accessToken, mediaId);
		File file = null;
		try {
			HttpURLConnection conn = (HttpURLConnection) new URL(url)
					.openConnection();
			conn.getContentType();
			String fileName = conn.getHeaderField("Content-disposition");
			Pattern p = Pattern.compile("\"[^\"]*\"");
			Matcher m = p.matcher(fileName);
			if (m.find()) {
				fileName = m.group();
				fileName = fileName.substring(1, fileName.length() - 1);
				downLoadFile(url, filepath, fileName);
			} else {
				JsonObject jo = JSON
						.parse(HTTPUtil.getContext(new URL(url).openStream()));
				HTTPUtil.doExeption(jo);
			}
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return file;
	}

	/**
	 * 将指定url资源下载到指定目录的文件中
	 * 
	 * @param url
	 * @param filepath
	 * @param fileName
	 * @return
	 */
	public static File downLoadFile(String url, String filepath, String fileName) {
		InputStream is = null;
		OutputStream os = null;
		File file = null;
		try {
			is = new URL(url).openStream();
			file = new File(filepath + fileName);
			int i = 0;
			while (file.exists()) {// 如果文件存在，循环修改文件名
				file = new File(filepath = fileName.replace(".", "(" + i++
						+ ")."));
			}
			os = new FileOutputStream(file);
			byte[] b = new byte[1024];
			int stepLength = 0;
			while ((stepLength = is.read(b)) != -1) {
				os.write(b, 0, stepLength);
			}
			os.flush();
			os.close();
			is.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if (os != null) {
					os.close();
				}
				if (is != null) {
					is.close();
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return file;
	}

	/**
	 * 发送客服消息
	 * 
	 * @param accessToken
	 * @param msg
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject sendCustomMsg(String accessToken, JsonObject msg)
			throws WeiXinException {
		return HTTPUtil.doPost(WeiXinUrlService.getSendCustomMsgUrl(accessToken), msg);
	}

	/**
	 * 获取json格式的微信用户数据
	 *
	 * @param accessToken
	 * @param openid
	 * @param lang
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getWeiXinUser(String accessToken,
			String openid, WXLang lang) throws WeiXinException {
		return HTTPUtil.doGet(WeiXinUrlService.getGetUserInfoUrl(accessToken, openid,
				lang));
	}

	/**
	 * 上传图文消息素材供群发消息使用【订阅号与服务号认证后均可用】
	 * 
	 * @param accessToken
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject uploadNews(String accessToken, JsonObject articles)
			throws WeiXinException {
		return HTTPUtil.doPost(WeiXinUrlService.getUploadNewsUrl(accessToken), articles);
	}

	/**
	 * 上传视频素材供群发使用【订阅号与服务号认证后均可用】
	 * 
	 * @param accessToken
	 * @param video
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject uploadVidoe(String accessToken, JsonObject video)
			throws WeiXinException {
		return HTTPUtil.doPost(WeiXinUrlService.getUploadVideoUrl(accessToken), video);
	}

	/**
	 * 根据分组进行群发【订阅号与服务号认证后均可用】
	 * 
	 * @param accessToken
	 * @param message
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject sendAll(String accessToken, JsonObject message)
			throws WeiXinException {
		return HTTPUtil.doPost(WeiXinUrlService.getSendAllUrl(accessToken), message);
	}

	/**
	 * 根据OpenID列表进行群发【订阅号不可用，服务号认证后可用】
	 * 
	 * @param accessToken
	 * @param message
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject send(String accessToken, JsonObject message)
			throws WeiXinException {
		return HTTPUtil.doPost(WeiXinUrlService.getSendUrl(accessToken), message);
	}
	/**
	 * 预览接口【订阅号与服务号认证后均可用】
	 * 
	 * @param accessToken
	 * @param message
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject preView(String accessToken, JsonObject message)
			throws WeiXinException {
		return HTTPUtil.doPost(WeiXinUrlService.getPreViewUrl(accessToken), message);
	}

	/**
	 * 发送模板数据
	 * 
	 * @param accessToken
	 * @param message
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject sendTemplateMsg(String accessToken,
			JsonObject message) throws WeiXinException {
		return HTTPUtil.doPost(WeiXinUrlService.getSendTemlateMsgUrl(accessToken),
				message);
	}

	/**
	 * 请注意，只有已经发送成功的消息才能删除删除消息只是将消息的图文详情页失效，已经收到的用户，还是能在其本地看到消息卡片。
	 * 另外，删除群发消息只能删除图文消息和视频消息，其他类型的消息一经发送，无法删除。【订阅号与服务号认证后均可用】
	 * 
	 * @param accessToken
	 * @param message 格式{"msg_id":30124}
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject delete(String accessToken, JsonObject message)
			throws WeiXinException {
		return HTTPUtil.doPost(WeiXinUrlService.getDeleteUrl(accessToken), message);
	}

	/**
	 * 创建分组
	 * 
	 * @param accessToken
	 * @param message
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject createGroup(String accessToken, JsonObject message)
			throws WeiXinException {
		return HTTPUtil.doPost(WeiXinUrlService.getCreateGroupUrl(accessToken), message);
	}

	/**
	 * 查询分组
	 * 
	 * @param accessToken
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getGroups(String accessToken)
			throws WeiXinException {
		return HTTPUtil.doGet(WeiXinUrlService.getCreateGroupUrl(accessToken));
	}

	/**
	 * 创建分组
	 * 
	 * @param accessToken
	 * @param message
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getGroupByOpenID(String accessToken,
			JsonObject message) throws WeiXinException {
		return HTTPUtil.doPost(WeiXinUrlService.getGetIdGroupUrl(accessToken), message);
	}

	/**
	 * 修改分组
	 * 
	 * @param accessToken
	 * @param message
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject updateGroup(String accessToken, JsonObject message)
			throws WeiXinException {
		return HTTPUtil.doPost(WeiXinUrlService.getUpdateGroupUrl(accessToken), message);
	}

	/**
	 * 修改用户分组
	 * 
	 * @param accessToken
	 * @param message
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject updateMemberGroup(String accessToken,
			JsonObject message) throws WeiXinException {
		return HTTPUtil.doPost(WeiXinUrlService.getUpdateMemberGroupUrl(accessToken),
				message);
	}

	/**
	 * 修改用户备注
	 * 
	 * @param accessToken
	 * @param message
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject updateRemark(String accessToken, JsonObject message)
			throws WeiXinException {
		return HTTPUtil.doPost(WeiXinUrlService.getUpdateRemarkUrl(accessToken), message);
	}

	/**
	 * 获取用户信息
	 * 
	 * @param accessToken
	 * @param openid
	 * @param lang
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getUserInfo(String accessToken, String openid,
			WXLang lang) throws WeiXinException {
		return HTTPUtil.doGet(WeiXinUrlService.getGetUserInfoUrl(accessToken, openid,
				lang));
	}

	/**
	 * 获取关注者openid列表
	 * 
	 * @param accessToken
	 * @param nextOpenid
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getUserOpenIDs(String accessToken,
			String nextOpenid) throws WeiXinException {
		return HTTPUtil.doGet(WeiXinUrlService.getGetUserOpenidsUrl(accessToken,
				nextOpenid));
	}
	/**
	 * 获取Oauth认证跳转页面Url
	 * @param appid
	 * @param returnUrl
	 * @param scope
	 * @param state
	 * @return
	 */
	public static String getGetCodeUrl(String appid, String returnUrl,
			WXOauthScope scope, String state) {
		return WeiXinUrlService.getGetCodeUrl(appid, returnUrl, scope, state);
	}

	/**
	 * 
	 * @param appid
	 * @param secret
	 * @param code
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getOauthAccessToken(String appid, String secret,
			String code) throws WeiXinException {
		return HTTPUtil.doGet(WeiXinUrlService.getGetOauthAccessTokenUrl(appid, secret,
				code));
	}

	/**
	 * 刷新oauth认证的accessToken
	 * 
	 * @param appid
	 * @param refreshToken
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject refreshOauthAccessToken(String appid,
			String refreshToken) throws WeiXinException {
		return HTTPUtil.doGet(WeiXinUrlService.getRefreshOauthAccessTokenUrl(
				refreshToken, appid));
	}

	/**
	 * 获取oauth用户信息
	 * 
	 * @param accessToken
	 * @param openid
	 * @param lang
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getOauthUserInfo(String accessToken,
			String openid, WXLang lang) throws WeiXinException {
		return HTTPUtil.doGet(WeiXinUrlService.getGetOauthUserInfoUrl(accessToken,
				openid, lang));
	}

	/**
	 * 检查用户oauth accessToken是否有效
	 * 
	 * @param accessToken
	 * @param openid
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject checkOauthAccessToken(String accessToken,
			String openid) throws WeiXinException {
		return HTTPUtil.doGet(WeiXinUrlService.getCheckOauthAccessTokenUrl(accessToken,
				openid));
	}

	/**
	 * 创建自定义菜单
	 * 
	 * @param accessToken
	 * @param menu
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject createMenu(String accessToken, JsonObject menu)
			throws WeiXinException {
		return HTTPUtil.doPost(WeiXinUrlService.getCreateMenuUrl(accessToken), menu);
	}

	/**
	 * 查询自定义菜单
	 * 
	 * @param accessToken
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getMenu(String accessToken) throws WeiXinException {
		return HTTPUtil.doGet(WeiXinUrlService.getGetMenuUrl(accessToken));
	}

	/**
	 * 删除自定义菜单
	 * 
	 * @param accessToken
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject deleteMenu(String accessToken)
			throws WeiXinException {
		return HTTPUtil.doGet(WeiXinUrlService.getDeleteMenuUrl(accessToken));
	}

	/**
	 * 创建二维码
	 * 
	 * @param accessToken
	 * @param codeInfo
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject createQrcode(String accessToken,
			JsonObject codeInfo) throws WeiXinException {
		return HTTPUtil.doPost(WeiXinUrlService.getCreateQRcodeUrl(accessToken),
				codeInfo);
	}

	/**
	 * 获取获取二维码的url
	 * 
	 * @param ticket
	 * @return
	 */
	public static String getGetQRcodeUrl(String ticket) {
		return WeiXinUrlService.getGetQRcodeByTicketUrl(ticket);
	}

	/**
	 * 长链接转短链接
	 * @param accessToken
	 * @param longUrl
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getShortUrl(String accessToken, String longUrl)
			throws WeiXinException {
		JsonObject message = new JsonObject();
		message.put(WXJsonName.ACTION, WXJsonValue.LONG2SHORT);
		message.put(WXJsonName.LONG_URL, longUrl);
		return HTTPUtil.doPost(WeiXinUrlService.getShortUrlUrl(accessToken), message);
	}
	/**
	 * 获取客服信息
	 * @param accessToken
	 * @param pageInfo
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getCSRecord(String accessToken,JsonObject pageInfo) throws WeiXinException{
		return HTTPUtil.doPost(WeiXinUrlService.getCustomServiceRecordUrl(accessToken), pageInfo);
	}
	/**
	 * 获取微信jsAccessToken
	 * @param accessToken
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getJsonAccessToken(String accessToken) throws WeiXinException{
		return HTTPUtil.doGet(WeiXinUrlService.getGetJsAccessTokenUrl(accessToken));
	}
	/**
	 * 获取用户增减数据<br/>
	 * 最大时间跨度7天
	 * @param accessToken
	 * @param datesInfo
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getUserSummary(String accessToken,JsonObject datesInfo) throws WeiXinException{
		return HTTPUtil.doPost(WeiXinUrlService.getGetUserSummaryURL(accessToken), datesInfo);
	}
	/**
	 * 获取累计用户数据<br/>
	 * 最大时间跨度7天
	 * @param accessToken
	 * @param datesInfo
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getUserCumulate(String accessToken,JsonObject datesInfo) throws WeiXinException{
		return HTTPUtil.doPost(WeiXinUrlService.getGetUserCumulateURL(accessToken), datesInfo);
	}
	/**
	 * 获取图文群发每日数据<br/>
	 * 最大时间跨度1天
	 * @param accessToken
	 * @param datesInfo
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getArticleSummary(String accessToken,JsonObject datesInfo) throws WeiXinException{
		return HTTPUtil.doPost(WeiXinUrlService.getGetArticleSummaryURL(accessToken), datesInfo);
	}
	/**
	 * 获取图文群发总数据<br/>
	 * 最大时间跨度1天
	 * @param accessToken
	 * @param datesInfo
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getArticleTotal(String accessToken,JsonObject datesInfo) throws WeiXinException{
		return HTTPUtil.doPost(WeiXinUrlService.getGetArticleTotalURL(accessToken), datesInfo);
	}
	/**
	 * 获取图文统计数据<br/>
	 * 最大时间跨度3天
	 * @param accessToken
	 * @param datesInfo
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getUserRead(String accessToken,JsonObject datesInfo) throws WeiXinException{
		return HTTPUtil.doPost(WeiXinUrlService.getGetUserReadURL(accessToken), datesInfo);
	}
	/**
	 * 获取图文统计分时数据<br/>
	 * 最大时间跨度1天
	 * @param accessToken
	 * @param datesInfo
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getUserReadHour(String accessToken,JsonObject datesInfo) throws WeiXinException{
		return HTTPUtil.doPost(WeiXinUrlService.getGetUserReadHourURL(accessToken), datesInfo);
	}
	/**
	 * 获取图文分享转发数据<br/>
	 * 最大时间跨度7天
	 * @param accessToken
	 * @param datesInfo
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getUserShare(String accessToken,JsonObject datesInfo) throws WeiXinException{
		return HTTPUtil.doPost(WeiXinUrlService.getGetUserShareURL(accessToken), datesInfo);
	}
	/**
	 * 获取图文分享转发分时数据<br/>
	 * 最大时间跨度1天
	 * @param accessToken
	 * @param datesInfo
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getUserShareHour(String accessToken,JsonObject datesInfo) throws WeiXinException{
		return HTTPUtil.doPost(WeiXinUrlService.getGetUserShareHourURL(accessToken), datesInfo);
	}
	/**
	 * 获取消息发送概况数据<br/>
	 * 最大时间跨度7天
	 * @param accessToken
	 * @param datesInfo
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getUpstreamMsg(String accessToken,JsonObject datesInfo) throws WeiXinException{
		return HTTPUtil.doPost(WeiXinUrlService.getGetUpstreamMsgURL(accessToken), datesInfo);
	}
	/**
	 * 获取消息发送概况分时数据<br/>
	 * 最大时间跨度1天
	 * @param accessToken
	 * @param datesInfo
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getUpstreamMsgHour(String accessToken,JsonObject datesInfo) throws WeiXinException{
		return HTTPUtil.doPost(WeiXinUrlService.getGetUpstreamMsgHourURL(accessToken), datesInfo);
	}
	/**
	 * 获取消息发送概况分周数据<br/>
	 * 最大时间跨度30天
	 * @param accessToken
	 * @param datesInfo
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getUpstreamMsgWeek(String accessToken,JsonObject datesInfo) throws WeiXinException{
		return HTTPUtil.doPost(WeiXinUrlService.getGetUpstreamMsgWeekURL(accessToken), datesInfo);
	}
	/**
	 * 获取消息发送概况分月数据<br/>
	 * 最大时间跨度30天
	 * @param accessToken
	 * @param datesInfo
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getUpstreamMsgMonth(String accessToken,JsonObject datesInfo) throws WeiXinException{
		return HTTPUtil.doPost(WeiXinUrlService.getGetUpstreamMsgMonthURL(accessToken), datesInfo);
	}
	/**
	 * 获取消息发送分布数据<br/>
	 * 最大时间跨度15天
	 * @param accessToken
	 * @param datesInfo
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getUpstreamMsgDist(String accessToken,JsonObject datesInfo) throws WeiXinException{
		return HTTPUtil.doPost(WeiXinUrlService.getGetUpstreamMsgDistURL(accessToken), datesInfo);
	}
	/**
	 * 获取消息发送分布分周数据<br/>
	 * 最大时间跨度30天
	 * @param accessToken
	 * @param datesInfo
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getUpstreamMsgDistWeek(String accessToken,JsonObject datesInfo) throws WeiXinException{
		return HTTPUtil.doPost(WeiXinUrlService.getGetUpstreamMsgDistWeekURL(accessToken), datesInfo);
	}
	/**
	 * 获取消息发送分布分月数据<br/>
	 * 最大时间跨度30天
	 * @param accessToken
	 * @param datesInfo
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getUpstreamMsgDistMonth(String accessToken,JsonObject datesInfo) throws WeiXinException{
		return HTTPUtil.doPost(WeiXinUrlService.getGetUpstreamMsgDistMonthURL(accessToken), datesInfo);
	}
	/**
	 * 获取接口分析数据<br/>
	 * 最大时间跨度30天
	 * @param accessToken
	 * @param datesInfo
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getInterfaceSummary(String accessToken,JsonObject datesInfo) throws WeiXinException{
		return HTTPUtil.doPost(WeiXinUrlService.getGetInterfaceSummaryURL(accessToken), datesInfo);
	}
	/**
	 * 获取接口分析分时数据<br/>
	 * 最大时间跨度1天
	 * @param accessToken
	 * @param datesInfo
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getInterfaceSummaryHour(String accessToken,JsonObject datesInfo) throws WeiXinException{
		return HTTPUtil.doPost(WeiXinUrlService.getGetInterfaceSummaryHourURL(accessToken), datesInfo);
	}

	/**
	 * 获取微小店商品
	 * @param accessToken
	 * @param datesInfo
	 * @return
	 * @throws WeiXinException
	 */
	public static JsonObject getMerchandise(String accessToken,JsonObject datesInfo) throws WeiXinException{
		return HTTPUtil.doPost(WeiXinUrlService.getGetMerchandiseUrl(accessToken), datesInfo);
	}

}
